home *** CD-ROM | disk | FTP | other *** search
/ Clickx 115 / Clickx 115.iso / software / tools / windows / tails-i386-0.16.iso / live / filesystem.squashfs / etc / init.d / haveged < prev    next >
Encoding:
Text File  |  2013-01-10  |  2.3 KB  |  101 lines

  1. #! /bin/sh
  2. ### BEGIN INIT INFO
  3. # Provides:          haveged
  4. # Required-Start:    $remote_fs
  5. # Required-Stop:     $remote_fs
  6. # Should-Start:      $syslog
  7. # Should-Stop:       $syslog
  8. # Default-Start:     2 3 4 5
  9. # Default-Stop:
  10. # Short-Description: Entropy daemon using the HAVEGE algorithm
  11. # Description:       haveged uses HAVEGE (HArdware Volatile Entropy Gathering
  12. #                    and Expansion) to maintain a pool of random bytes used
  13. #                    to fill /dev/random whenever necessary.
  14. ### END INIT INFO
  15.  
  16. # Do NOT "set -e"
  17.  
  18. PATH=/sbin:/usr/sbin:/bin:/usr/bin
  19. DESC="entropy daemon"
  20. NAME=haveged
  21. DAEMON=/usr/sbin/$NAME
  22. DAEMON_ARGS=""
  23. PIDFILE=/var/run/$NAME.pid
  24. SCRIPTNAME=/etc/init.d/$NAME
  25.  
  26. # Exit if the package is not installed
  27. [ -x "$DAEMON" ] || exit 0
  28.  
  29. # Read configuration variable file if it is present
  30. [ -r /etc/default/$NAME ] && . /etc/default/$NAME
  31.  
  32. # Load the VERBOSE setting and other rcS variables
  33. . /lib/init/vars.sh
  34.  
  35. # Define LSB log_* functions.
  36. . /lib/lsb/init-functions
  37.  
  38. do_start()
  39. {
  40.     start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON --test > /dev/null \
  41.         || return 1
  42.     start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON -- \
  43.         $DAEMON_ARGS \
  44.         || return 2
  45. }
  46.  
  47. do_stop()
  48. {
  49.     start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 --pidfile $PIDFILE --name $NAME
  50.     RETVAL="$?"
  51.     [ "$RETVAL" = 2 ] && return 2
  52.     rm -f $PIDFILE
  53.     return "$RETVAL"
  54. }
  55.  
  56. case "$1" in
  57.     start)
  58.     [ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME"
  59.     do_start
  60.     case "$?" in
  61.         0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
  62.         2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
  63.     esac
  64.     ;;
  65.     stop)
  66.     [ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME"
  67.     do_stop
  68.     case "$?" in
  69.         0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
  70.         2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
  71.     esac
  72.     ;;
  73.     status)
  74.        status_of_proc "$DAEMON" "$NAME" && exit 0 || exit $?
  75.        ;;
  76.     restart|force-reload)
  77.     log_daemon_msg "Restarting $DESC" "$NAME"
  78.     do_stop
  79.     case "$?" in
  80.         0|1)
  81.         do_start
  82.         case "$?" in
  83.             0) log_end_msg 0 ;;
  84.             1) log_end_msg 1 ;; # Old process is still running
  85.             *) log_end_msg 1 ;; # Failed to start
  86.         esac
  87.         ;;
  88.         *)
  89.         # Failed to stop
  90.         log_end_msg 1
  91.         ;;
  92.     esac
  93.     ;;
  94.     *)
  95.     echo "Usage: $SCRIPTNAME {start|stop|status|restart|force-reload}" >&2
  96.     exit 3
  97.     ;;
  98. esac
  99.  
  100. :
  101.